package learnonline.web.servlet;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

@WebServlet("/userjudge")
public class UserjudgeServlet extends HttpServlet{
	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		String userName = null;
		userName = (String) req.getSession().getAttribute("username");
		int authority = 0;
		
		System.out.println(userName);
		if(userName!=null){
			authority= (int) req.getSession().getAttribute("authority");
			System.out.println(authority);
			if(authority==2){
				req.getRequestDispatcher("teachermanage").forward(req, resp);
			}else if(authority==1){
				req.getRequestDispatcher("userdetail").forward(req, resp);
			}
			
		}else{
			resp.sendRedirect("Login.jsp");
		}
	}
}
